package com.chunguang.study.controller;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/session")
public class SessionShareController2 {
	
	private static final Logger logger =  LoggerFactory.getLogger(SessionShareController2.class);
	/**
	 * 只要部署两个应用的时候，在同一个浏览器访问两个应用的时候会产生同样的会话
	 * @param map
	 * @param httpSession
	 * @return
	 */
	
	@RequestMapping(value = "/index")
	public String index(ModelMap map, HttpSession httpSession) {
		map.put("title", "第一个应用：sessionID=" + httpSession.getId());
		logger.info("sessionID=" + httpSession.getId());
		return "index";
	}

	
	@RequestMapping("error")
	public String error(ModelMap map){
		throw new RuntimeException("测试异常");
	}

}
